package GameMain.View.GameTest
{
	import Engine.AIUGame.AIGDate;
	import Engine.AIUGame.AIGame;
	import Engine.AIUGame.AISprite;
	
	import GameMain.Model.PlayerModel;
	import GameMain.View.GameCenter.BitMapClass;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class GameTest extends AIGame
	{
		
		
		private var px:int = 0;
		private var py:int = 0;
		private var rect:Rectangle = new Rectangle();
		private var _fill:BitmapData;
		private var bit:BitmapData;
		private var bit2:BitmapData;
		private var position:Point = new Point;
		
		private var flPos:Point = new Point;
		
		public function GameTest()
		{
			
			
			
			super(700, 500);
			
			
			bit = (new PlayerModel.bodyImgClass) as BitmapData;
			
			bit2 = new BitmapData(bit.width,bit.height,true,0x00000000);
			
			bit2.draw(bit);
			var bitmap:Bitmap = new Bitmap(bit2)
			//this.addChild(bitmap);
			bitmap.x = 100;bitmap.y = 100;
			
			rect.width = bit2.width;
			rect.height = bit2.height;
			rect.x = 0;
			rect.y = 0;
			
			//_fill = new BitmapData(bit2.width,bit2.height,true,0);
			
			var sp:AISprite = new AISprite(100,100);
			sp.loadGraphic(bit,true,true,282,229);
			sp.addAnimation("run",[4,5,6,7],6);
			
			AIGDate.GameGroup.add(sp);
			sp.play("run");
			
			//addEventListener(Event.ENTER_FRAME,onEnterFrame);
		}
		
		
		private function onEnterFrame(e:Event):void
		{
			_fill.fillRect(rect,0x00000000);
			
			px++;
			py++;
			
			bit2.copyPixels(_fill,rect,position,null,null,false);
			
			flPos.x = px;
			flPos.y = py;
			
			bit2.copyPixels(bit,rect,flPos,null,null,true);
			
		}
	}
}